home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / errcode.bat < prev    next >
DOS Batch File  |  1994-08-31  |  2KB  |  57 lines

  1. @echo off
  2. !  errcode.bat    Finds the error code corresponding to a given error message
  3. !
  4. !  errcode message
  5. !
  6. !  where 'message' is the message (or the beginning of the message) of which we
  7. !  need the error code.
  8. !
  9. !  DO NOT USE AS ARGUMENTS STRINGS LONGER THAN ABOUT 50 CHARACTERS, otherwise
  10. !  the batch will fail because some commands will exceed the maximum length of
  11. !  127 characters.
  12. !
  13. !  Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
  14. !
  15.  
  16.     ! ensure that the first parameter is there and that the second one is not
  17.     set doserr=13
  18.     if not "%2x" == "x" goto ERR_LBL
  19.     if "%1x" == "x" goto ERR_LBL
  20.  
  21.     ! ensure that the first parameter is non-numeric
  22.     set errcode_check=z%1
  23.     incr errcode_check by 1
  24.     set errcode_mess=%1
  25.     incr errcode_mess by 1
  26.     incr -errcode_mess by z
  27.     if not "%errcode_mess%" == "%errcode_check%" goto ERR_LBL
  28.  
  29.     ! loop through all the error codes until a match is found
  30.     set errcode_check=%1
  31.     set doserr=72
  32.     set errcode_value=0
  33. :NEXT_CODE_LBL
  34.     if not %doserr% == 72 goto ERR_LBL
  35.     onerror NO_MATCH_LBL
  36.     incr errcode_value
  37.     show %errcode_value% errcode_mess
  38.     decr -errcode_mess by "%errcode_check%"
  39.     show %errcode_value% errcode_mess
  40.     echo %errcode_value%: "%errcode_mess%"
  41.     goto DONE_LBL
  42. :NO_MATCH_LBL
  43.     if not %doserr% == 72 goto ERR_LBL
  44.     onerror NEXT_CODE_LBL
  45.     incr errcode_mess by z
  46.     decr errcode_mess by "%errcode_value%z"
  47.     echo "%1" does not correspond to any error code
  48.     goto DONE_LBL
  49.  
  50. :ERR_LBL
  51.     show %doserr%
  52.  
  53. :DONE_LBL
  54.     set errcode_check=
  55.     set errcode_value=
  56.     set errcode_mess=
  57.